package com.example.mybatisplus.vo;

import com.example.mybatisplus.exception.AppExceptionCodeMsg;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ResultBean {
	private Integer code;
	private String msg;
	private Object data;

	public ResultBean(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public static ResultBean SUCCESS(){
		return new ResultBean(200,"success",null);
	}

	public static ResultBean SUCCESS(Object data){
		return new ResultBean(200,"success",data);
	}

	public static ResultBean ERROR(){
		return new ResultBean(500,"服务器内部错误");
	}

	public static ResultBean ERROR(Integer code,String msg){
		return new ResultBean(code,msg);
	}

	public static ResultBean ERROR(String msg){
		return new ResultBean(500,msg);
	}

	public static ResultBean ERROR(AppExceptionCodeMsg codeMsg){
		return new ResultBean(codeMsg.getCode(), codeMsg.getMsg());
	}
}
